#-*- coding: utf-8 -*-

#This file is part of pyLot library.
#
# pyLot is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyLot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with pyLot.  If not, see <http://www.gnu.org/licenses/>.

__author__ = u'Guillaume Baty'
__copyright__ = u"Copyright 2011-2012 (C) andheo"
__credits__ = [u'Guillaume Baty']
__license__ = "GNU Lesser General Public License"

__all__ = ['About']

from Qt4 import QtGui, QtCore

from _pylot.qtgui.tools import generate_pyfile_from_uifile
from _pylot.minimal.utils import get_data

import pkg_resources

generate_pyfile_from_uifile(__name__)
from .designer._about import Ui_About
class About(QtGui.QWidget, Ui_About):

  alias = u'About pyLot'
  name = 'pyLot'
  identifier = 'pyLot.about.pyLot'

  def __init__(self):
    QtGui.QWidget.__init__(self)
    Ui_About.__init__(self)
    self.setupUi(self)

    path = get_data('_pylot', u'data/logos/python_no_text.png')

    self.l_icon.setText(u'')
    self.l_icon.setPixmap(QtGui.QIcon(path).pixmap(QtCore.QSize(90, 90)))

    distribution = pkg_resources.get_distribution(u'pyLot')
    name = distribution.project_name
    version = distribution.version

    self.l_title.setText(u'''
      <html><head/><body><p>
      <span style=" font-size:12pt; font-weight:600; color:#5500ff;">
      %(NAME)s, 
      </span>
      <span style=" font-size:12pt; color:#5500ff;">
      version %(VERSION)s
      </span>
      </p></body></html>
      ''' % dict(NAME=name, VERSION=version)
      )

